package datautils;
import java.io.Serializable;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: HAiL
 * Date: 10.11.13
 * Time: 20:47
 * To change this template use File | Settings | File Templates.
 */
public class Results implements Serializable {
    Map<String, Integer> results;
    public int minValue;
    public String minKey;
    public Results() {
        results = new LinkedHashMap<>();
        results.put("Общеобразовательное",0);
        results.put("основы ООП",0);
    }

    public void increaseResults(String key) {
       for(Map.Entry <String, Integer> entry : results.entrySet())
          if(key.equals(entry.getKey())){
             entry.setValue(entry.getValue()+1);
              minValue=entry.getValue();
              minKey=entry.getKey();
          }
    }

    public  void printResults (){
      for(Map.Entry <String, Integer> entry : results.entrySet())
        System.out.println(entry.getKey()+": "+entry.getValue());
    }

    public void getMinValueAndKey(){
        for(Map.Entry <String, Integer> entry : results.entrySet())
           if(entry.getValue()<minValue){
               minValue=entry.getValue();
               minKey = entry.getKey();
           }
    }

    public String getWorseUsersKnownTheme(){
        getMinValueAndKey();
        return minKey;
    }
}
